home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / HyperCard / Balloon XCMD v1.01 / Balloon.c < prev    next >
C/C++ Source or Header  |  1992-04-19  |  3KB  |  82 lines

  1. /************************************************************************/
  2. /*                            Balloon XCMD V1.0.1                            */
  3. /*                                                                        */
  4. /*    Usage:    balloon false        -- switch help off                        */
  5. /*            balloon true        -- switch help on                        */
  6. /*            balloon                -- remove balloon                        */
  7. /*            balloon    helpString    -- show balloon                            */
  8. /*                                                                        */
  9. /*    No balloon is shown if the mouseLoc is not within the target or a    */
  10. /*    previous balloon is visible.                                        */
  11. /*    Compile as: Code Resource, Type XCMD, Purgeable                        */
  12. /*    Freeware written in Think C 5.0 by R. Geisler 1992.                    */
  13. /************************************************************************/
  14.  
  15.  
  16. #include <Balloons.h>
  17. #include <GestaltEqu.h>
  18. #include <HyperXCmd.h>
  19. #include <SetupA4.h>
  20. #include <string.h>
  21. #define retUnav "balloon help unavailable"
  22. #define retOff "balloon help off"
  23.  
  24.  
  25. HMMessageRecord myMsg=
  26. {    khmmString    };
  27. long ftr;
  28. Point tip;
  29. Rect aRect;
  30. Handle hit, pos;
  31.  
  32.  
  33. pascal main(XCmdPtr paramPtr)
  34. {    RememberA0();
  35.     SetUpA4();
  36.     if(Gestalt(gestaltHelpMgrAttr, &ftr)||!(ftr&1<<gestaltHelpMgrPresent))
  37.     {    paramPtr->returnValue=NewHandle(sizeof(retUnav));
  38.         strcpy(*paramPtr->returnValue, retUnav);    }    /*    help unav.    */
  39.     else
  40.     {    if(!paramPtr->paramCount)        /*    remove balloon                */
  41.             HMRemoveBalloon();
  42.         else if(!strcmp(*paramPtr->params[0], "true"))
  43.             HMSetBalloons(true);        /*    switch help on                */
  44.         else if(!strcmp(*paramPtr->params[0], "false"))
  45.             HMSetBalloons(false);        /*    switch help off                */
  46.         else if(!HMIsBalloon())
  47.         {    hit=EvalExpr(paramPtr, 
  48.                 "\pthe mouseLoc is within the rect of the target");
  49.             if(!strcmp("true", *hit))    /*    show balloon                */
  50.             {    pos=EvalExpr(paramPtr, 
  51.                     "\pthe mouseV + the top of card window");
  52.                 tip.v=atoi(*pos);
  53.                 DisposHandle(pos);
  54.                 pos=EvalExpr(paramPtr, 
  55.                     "\pthe mouseH + the left of card window");
  56.                 tip.h=atoi(*pos);
  57.                 DisposHandle(pos);
  58.                 pos=EvalExpr(paramPtr, 
  59.                     "\pthe top of the target + the top of card window");
  60.                 aRect.top=atoi(*pos);
  61.                 DisposHandle(pos);
  62.                 pos=EvalExpr(paramPtr, 
  63.                     "\pthe left of the target + the left of card window");
  64.                 aRect.left=atoi(*pos);
  65.                 DisposHandle(pos);
  66.                 pos=EvalExpr(paramPtr, 
  67.                     "\pthe bottom of the target + the top of card window");
  68.                 aRect.bottom=atoi(*pos);
  69.                 DisposHandle(pos);
  70.                 pos=EvalExpr(paramPtr, 
  71.                     "\pthe right of the target + the left of card window");
  72.                 aRect.right=atoi(*pos);
  73.                 DisposHandle(pos);
  74.                 ZeroToPas(paramPtr, *paramPtr->params[0], 
  75.                     (StringPtr)myMsg.u.hmmString);
  76.                 HMShowBalloon(&myMsg, tip, &aRect, 0L, 0, 6, 
  77.                         kHMSaveBitsWindow);    }
  78.             DisposHandle(hit);    }
  79.         if (!HMGetBalloons())            /*    help is off                    */
  80.         {    paramPtr->returnValue=NewHandle(sizeof(retOff));
  81.             strcpy(*paramPtr->returnValue, retOff);    }    }
  82.     RestoreA4();    }